package com.yi.wood.web.util;

import java.util.Random;

/**
 * @author MoYi
 * Created time 2019/5/29 16:13
 */
public class CommonStrUtil {


    private final static char[] CHARS = new char[]{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','P','Q'
            ,'R','S','T','U','V','W','X','Y','Z','2','3','4','5','6','7','8','9','+','-','(',')'};

    public static String getRandomStr(int size){
        StringBuilder resultStr = new StringBuilder();
        Random random = new Random();
        while (size > 0){
            int index = random.nextInt(CHARS.length);
            resultStr.append(CHARS[index]);
            size--;
        }
        return resultStr.toString();
    }

    public static char[] getRandomChar(int size){
        char[] chars = new char[size];
        Random random = new Random();
        while (size > 0){
            int index = random.nextInt(CHARS.length);
            chars[size] = CHARS[index];
            size--;
        }
        return chars;
    }
}
